home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC]
/
NeXTSTEP 3.3 Dev Intel.iso
/
usr
/
sybase
/
doc
/
dbrettype.man
< prev
next >
Wrap
Text File
|
1993-04-22
|
6KB
|
155 lines
1 Version 4.0 -- 5/1/89 dbrettype
______________________________________________________________________
NAME: dbrettype
FUNCTION:
Determine the datatype of a return parameter value generated by a
stored procedure.
SYNTAX:
int dbrettype(dbproc, retnum)
DBPROCESS *dbproc;
int retnum;
dbrettype Version 4.0 -- 5/1/89 2
______________________________________________________________________
COMMENTS:
o dbrettype() returns the datatype of a return parameter value
generated by a stored procedure. It is useful in conjunction
with remote procedure calls and EXECUTE statements on stored
procedures.
o Transact-SQL stored procedures can return values for specified
"return parameters." Changes made to the value of a return
parameter inside the stored procedure are then available to the
program that called the procedure. This is analogous to the
"pass by reference" facility available in some programming
languages.
For a parameter to function as a return parameter, it must be
declared as such within the stored procedure. The EXECUTE
statement or remote procedure call that calls the stored pro-
cedure must also indicate that the parameter should function as
3 Version 4.0 -- 5/1/89 dbrettype
______________________________________________________________________
a return parameter. In the case of a remote procedure call, it
is the dbrpcparam() routine that specifies whether a parameter
is a return parameter.
o When executing a stored procedure, the server returns any
parameter values immediately after returning all other results.
Therefore, the application can call dbrettype() only after pro-
cessing the stored procedure's results by calling dbresults(),
as well as dbnextrow() if appropriate. (Note that a stored
procedure can generate several sets of results-one for each
SELECT it contains. Before the application can call dbret-
type() or any other routines that process return parameters, it
must call dbresults() and dbnextrow() as many times as neces-
sary to process all the results.)
o If the stored procedure is invoked with a remote procedure
call, the return parameter values are automatically available
to the application. If, on the other hand, the stored
dbrettype Version 4.0 -- 5/1/89 4
______________________________________________________________________
procedure is invoked with an EXECUTE statement, the return
parameter values are available only if the command batch con-
taining the EXECUTE statement uses local variables, not con-
stants, for the return parameters.
o dbrettype() actually returns an integer token value for the
datatype (SYBCHAR, SYBFLT8, etc.). To convert the token value
into a readable token string, use dbprtype(). See the
dbprtype() manual page for a list of all token values and their
equivalent token strings.
o For a list of SQL Server datatypes, see the manual page for
types.
o Other routines return additional information about return
parameter values:
o dbnumrets() returns the total number of return parameter
values.
5 Version 4.0 -- 5/1/89 dbrettype
______________________________________________________________________
o dbretdata() returns a pointer to a parameter value.
o dbretlen() returns the length of a parameter value.
o dbretname() returns the name of a parameter value.
o For an example of this routine, see Example 8 in the DB-Library
Reference Supplement.
PARAMETERS:
dbproc - A pointer to the DBPROCESS structure that provides the
connection for a particular front-end/SQL Server process. It
contains all the information that DB-Library uses to manage
communications and data between the front end and SQL Server.
retnum - The number of the return parameter value of interest.
The first return value is 1. Values are returned in the same
order as the parameters were originally specified in the
stored procedure's CREATE PROCEDURE statement. (Note that
dbrettype Version 4.0 -- 5/1/89 6
______________________________________________________________________
this is not necessarily the same order as specified in the
remote procedure call.) When specifying retnum, non-return
parameters do not count. For example, if the second parame-
ter in a stored procedure is the only return parameter, its
retnum is 1, not 2.
RETURNS:
A token value for the datatype of the specified return value.
In a few cases, the token value returned by this routine may not
correspond exactly with the column's SQL Server datatype:
o SYBVARCHAR is returned as SYBCHAR.
o SYBVARBINARY is returned as SYBBINARY.
o SYBDATETIMN is returned as SYBDATETIME.
o SYBMONEYN is returned as SYBMONEY.
7 Version 4.0 -- 5/1/89 dbrettype
______________________________________________________________________
o SYBFLTN is returned as SYBFLT8.
o SYBINTN is returned as SYBINT1, SYBINT2, or SYBINT4, depending
on the actual type of the SYBINTN.
If retnum is out of range, -1 is returned.
SEE ALSO:
dbnextrow, dbnumrets, dbprtype, dbresults, dbretdata, dbretlen,
dbretname, dbrpcinit, dbrpcparam